package com.lagou.cl.bootstrap;

import com.lagou.cl.client.RpcConsumer;
import com.lagou.cl.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 程  林
 * @date 2020-05-23 19:32
 * @description //
 * @since V1.0.0
 */
@Component
@Slf4j
public class ClientConsumerBootStrap extends Thread {

	@Autowired
	private RpcConsumer rpcConsumer;

	@Override
	public void run() {

		try {
			rpcConsumer.startUp();
		} catch (Exception e) {
			e.printStackTrace();
		}

		AccountService proxy = (AccountService) rpcConsumer.createProxy(AccountService.class);

		while (true) {

			try {
				Thread.sleep(1000);
				String res = proxy.say("hello world");
				//log.info("响应数据： " + res);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
